<?php

add_filter( 'rewrite_rules_array','wp_users_rewrite' );
add_action( 'wp_loaded','wp_users_rewrite_init' );

// flush_rules() if our rules are not yet included
function wp_users_rewrite_init(){
	$rules = get_option( 'rewrite_rules' );

	if ( ! isset( $rules['(members)/(\w*)$'] ) ) {
		global $wp_rewrite;
	   	$wp_rewrite->flush_rules();
	}
}

// Adding a new rule
function wp_users_rewrite( $rules )
{
	add_rewrite_tag('%wpusername%','(member)/(\w*)$', 'member/?uid=' );
	$wpusername = $wp_query->query_vars['wpusername'];
	$wpuser = get_userdatabylogin($wpusername);
	$wpuserid = $wpusername->ID;
	var_dump($wpusername);
	$newrules = array();
	$newrules['(member)/(\w*)$'] = 'member/?uid=' . $wpuserid;
	
	return $newrules + $rules;
}

?>